package com.jzy.bxb.manage.interceptor;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;

import com.jzy.bxb.model.constant.AppConstant;
import com.jzy.bxb.model.mongo.entity.User;

/**
 * 登录状态检查，临时处理，以后调整
 *
 * @author JiangZhiYong
 * @date 2017-05-23 QQ:359135103
 */
public class UserInterceptor extends HandlerInterceptorAdapter {

	@Override
	public void postHandle(HttpServletRequest request, HttpServletResponse response, Object obj, ModelAndView mav)
			throws Exception {
		User result = (User) (request.getSession()).getAttribute(AppConstant.USER);
		if (result == null) {
			mav.setViewName("redirect:/login");
		}
	}

}
